package com.shop.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.AllowedMethods;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.shop.entity.Dept;
import com.shop.service.DeptService;
@Controller
@AllowedMethods("findAll,deleteDept")
public class DeptAction extends ActionSupport {
	@Resource
	private DeptService deptService;
	private Dept dept;
	@Action(value="deptAction_findAll",results={
			@Result(name="success",location="/success.jsp")
	})
	public String findAll(){
		List<Dept> list = deptService.findAll();
		ActionContext.getContext().put("list", list);
		return SUCCESS;
	}
	@Action(value="deptAction_deleteDept",results={
			@Result(name="list",location="deptAction_findAll",type="redirectAction")
	})
	public String deleteDept(){
		int result = deptService.deleteDept(dept.getDeptNo());
		return "list";
	}
	
	
	public DeptService getDeptService() {
		return deptService;
	}
	public void setDeptService(DeptService deptService) {
		this.deptService = deptService;
	}
	public Dept getDept() {
		return dept;
	}
	public void setDept(Dept dept) {
		this.dept = dept;
	}
	
}
